<?php
/*
Copyright (C) 2009 de Flotte Maxence

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
?>
<?php
//gestion des droits

function isReadable($user,$group,$userR,$groupR,$otherR) {
	//Tout le monde a droit de lire
	if($otherR)
		return true;
	//si l'utilisateur n'est pas connecté
	if(!isset($_SESSION['user']))
		return false;
	//le groupe a le droit de lire
	if($groupR and in_array($group,$_SESSION['group']))
		return true;
	//l'utilisateur Ã  le droit de lire
	if($userR and $user == $_SESSION['user'])
		return true;
	//L'utilisateur n'a pas le droit de lire
	return false;
}
function labelIsReadable() {
	return isReadable($GLOBALS['label_user'],$GLOBALS['label_group'],$GLOBALS['label_userR'],$GLOBALS['label_groupR'],$GLOBALS['label_otherR']);
}
function labelIsWritable() {
	return isReadable($GLOBALS['label_user'],$GLOBALS['label_group'],$GLOBALS['label_userW'],$GLOBALS['label_groupW'],$GLOBALS['label_otherW']);
}

?>